<?php foreach($chitiets as $chitiet):?>
<div id="<?php echo $chitiet['MaSanPham']?>" class="chitietsanpham ui-widget-content">
<?php if($chitiet['AnhSanPham'] == null || $chitiet['AnhSanPham'] == '' ) $chitiet['AnhSanPham'] = 'noimage.jpg'?>
<img src="<?=base_url('images/product/'.$chitiet['AnhSanPham'])?>" class="anhsanpham"/>
<div class="thongtin">
    <div class="duoi">Tên sản phẩm: <span class="tensanpham"><?php echo $chitiet['TenSanPham']?></span></div>
    <div class="duoi">Giá: <span class="giaban"><?php echo number_format($chitiet['GiaBan'])?>VND</span></div>
    <div class="duoi">Trạng thái: <span class="trangthai"><?php if($chitiet['TenSanPham'] ==0) echo 'Hết Hàng'; else echo 'Còn Hàng';?></span></div>
    <div class="duoi">Loại sản phẩm: <span class="tieude"><?php echo $chitiet['TenLoaiSP']?></span></div>
    <div class="duoi">Ngày đăng: <span class="ngaydang"><?php echo $chitiet['NgayDang']?></span></div>
    <div class="duoi">
        <div class="basic" title="<?php echo $chitiet['DiemDanhGia'] ?>/10">
            <div class="jRatingColor"></div>
            <div class="jRatingAverage" style="width: <?php echo (floatval($chitiet['DiemDanhGia'])/10)*230?>px;"></div>
            <div class="jStar"></div>
        </div>
    </div>
    <button class="lienhe ui-button ui-state-active ui-corner-all">Liên hệ</button>
    <button class="xembinhluan ui-state-default ui-corner-all" title="Xem Bình Luận">
        <span class="ui-icon ui-icon-comment"></span>
    </button>
</div>
<div class="mota">
    <p class="noidungmota"><?php echo $chitiet['MoTa']?></p>
</div>
</div>
<?php endforeach;?>
<div class="chuabinhluan"></div>
<script>
    $('.lienhe').click(function(){
        var masp = $(this).parent().parent('.chitietsanpham').attr('id');
        $.ajax({
            type: 'POST',
            url: '<?=base_url('index.php/taikhoan_controller/chitietnguoidang')?>',
            data: {masp : masp},
            success: function(data){
                $('.content').html(data);
            }
        });
    });
    $('.xembinhluan').click(function(){
        var masp = $(this).parent().parent('.chitietsanpham').attr('id');
        $.ajax({
            type: 'POST',
            url: '<?=base_url('index.php/binhluan_controller/xembinhluan')?>',
            data: {masp:masp},
            success: function(data){
                $('.chuabinhluan').html(data);
            }
        });
    });
</script>